﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;

namespace Altairis.MailToolkit.ListManager {
    public class Global : System.Web.HttpApplication {

        protected void Application_Start(object sender, EventArgs e) {
            // Public
            RouteTable.Routes.MapPageRoute("HomePage", "", "~/Pages/HomePage.aspx");
            RouteTable.Routes.MapPageRoute("RequestVerification", "{operation}/{list}/{code}/{email}", "~/Pages/Verify.aspx", false, null, new RouteValueDictionary(new {
                operation = "^[sr]$",                                       // "s" or "r"
                list = "^[a-z0-9-_.]+$",                                    // alphanumeric list name
                code = "^[A-Za-z0-9-_]{27}$",                               // base64-encoded value without padding
                email = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"   // e-mail address
            }));
            RouteTable.Routes.MapPageRoute("About", "about", "~/Pages/About.aspx");
            RouteTable.Routes.MapPageRoute("Login", "login", "~/Pages/Login.aspx");
            RouteTable.Routes.MapPageRoute("Logout", "logout", "~/Pages/Login.aspx", false, null, null, new RouteValueDictionary(new { logout = true }));

            // Administration
            RouteTable.Routes.MapPageRoute("AdminHomePage", "admin", "~/Pages/Admin/HomePage.aspx");
            RouteTable.Routes.MapPageRoute("AdminSendMessage", "admin/send", "~/Pages/Admin/SendMessage.aspx");
            RouteTable.Routes.MapPageRoute("AdminImportMembers", "admin/import/{listname}", "~/Pages/Admin/ImportMembers.aspx");
        }

    }
}